package com.wushi.lenovo.asia5b.app_ui.good.adapter;

import android.support.annotation.Nullable;
import android.widget.CheckBox;
import android.widget.CompoundButton;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.wushi.lenovo.asia5b.R;
import com.wushi.lenovo.asia5b.app_model.good.OrderPackServiceModel;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by zhangyuncai on 2019/2/16.
 */
public class AddServicesAdapter extends BaseQuickAdapter<OrderPackServiceModel, BaseViewHolder> {

    public final List<OrderPackServiceModel> selectAddService = new ArrayList<>();

    public AddServicesAdapter(@Nullable List<OrderPackServiceModel> data) {
        super(R.layout.item_orderpayment_servicesadapter, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, OrderPackServiceModel item) {
        CheckBox radioButton = (CheckBox) helper.itemView;
        radioButton.setText(item.title);
        radioButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (radioButton.isChecked()) {
                    selectAddService.add(item);
                } else {
                    selectAddService.remove(item);
                }
            }
        });
    }
}
